nl.ivojonker.icn.configuration
Class ConfigurationJSON

java.lang.Object
  extended by nl.ivojonker.icn.configuration.ConfigurationJSON

public class ConfigurationJSON
extends java.lang.Object

A helper class to serialize and deserialize the configuration as JSON. This is intentionally an external class so the Configuration.java can be used on webspheres without the com.ibm.json libraries. Preferably a decent json serializer/deserializer i used such as gson of jackson. But instead custom functions are made to convert from ConfigurationEntry to JSONObject

Author:
nl.ivojonker

Constructor Summary
ConfigurationJSON()
           
 
Method Summary
static com.ibm.json.java.JSONArray getConfigAsJSONArray(boolean exposedOnly)
          Retrieve the configuration as JSONArray.
static void persistConfigFromJSONArray(com.ibm.json.java.JSONArray configToPersist)
           
private static com.ibm.json.java.JSONObject translate(ConfigurationEntry entry)
           
private static java.util.ArrayList<ConfigurationEntry> translate(com.ibm.json.java.JSONArray json)
           
private static ConfigurationEntry translate(com.ibm.json.java.JSONObject json)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationJSON

public ConfigurationJSON()
Method Detail

getConfigAsJSONArray

public static com.ibm.json.java.JSONArray getConfigAsJSONArray(boolean exposedOnly)
                                                        throws java.sql.SQLException
Retrieve the configuration as JSONArray.

Parameters:
exposedOnly - filter setting to serialize only those entries that are marked 'exposed' (e.g. passwords shouldnt be exposed as they're viewable in plain text)
Returns:
Throws:
java.sql.SQLException

persistConfigFromJSONArray

public static void persistConfigFromJSONArray(com.ibm.json.java.JSONArray configToPersist)
                                       throws java.sql.SQLException
Throws:
java.sql.SQLException

translate

private static java.util.ArrayList<ConfigurationEntry> translate(com.ibm.json.java.JSONArray json)

translate

private static ConfigurationEntry translate(com.ibm.json.java.JSONObject json)

translate

private static com.ibm.json.java.JSONObject translate(ConfigurationEntry entry)